<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*    var num = 10;
           // 基本数据类型的复制， 是可以将值直接复制一份给一个新的变量
           var num1 = num;
           num1 = 100;
           console.log(num1); // 100
           console.log(num); // 10 */


        // 复杂数据类型是存储在堆中的 赋值的变量是一个地址（指向）
        // 基本数据类型是存储在栈中的 赋值给变量的是值本身

        //var arr = [12, 23, 34];
        /* var arr1 = arr;
        arr1[0] = 'aaa';
        console.log(arr1); // ['aaa', 23, 34]
        console.log(arr); // ['aaa', 23, 34] */

        /* var arr2 = [];
        for (var i = 0; i < arr.length; i++) {
            arr2.push(arr[i]);
        }
        arr2[0] = 'aaa';
        console.log(arr2); // [aaa,23,34]
        console.log(arr); // [12,23,34] */

        /*    var obj = {
               name: "lili",
               age: 18,
           }
    */
        /*  var obj2 = {};
         for (var key in obj) {
             obj2[key] = obj[key]
         }
         obj2.name = "nana";
         console.log(obj2); //{name: "nana",age:18}
         console.log(obj);// {name: "lili",age:18} */

        /* 
                var obj2 = Object.assign({}, obj);
                obj2.name = "nana";
                console.log(obj2); // {name: 'nana', age: 18}
                console.log(obj); // {name: 'lili', age: 18} */


        var data = [{
            title: "标题一",
            list: ["aaa", 'bbb', 'ccc'],
            author: {
                name: "lili"

            }
        }, {
            title: "标题二",
            list: ["a", 'b', 'c'],
            author: {
                name: "nana",
            }

        }]
        var data2 = [];
        for (var i = 0; i < data.length; i++) {
            // data2.push(data[i]);

            var o = {};
            for (var key in data[i]) {
                o[key] = data[i][key];
            }
            data2.push(o);
        }
        data2[0].title = "ninini11111"
        console.log(data2);
        console.log(data);

        data2[0].list[0] = "haohaohao66666"
        console.log(data2);
        console.log(data);
    </script>
</body>

</html>